package com.neusoft.work.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.work.po.Customer;
import com.neusoft.work.po.PageResponseBean;
import com.neusoft.work.po.ResponseBean;
import com.neusoft.work.service.CustomerService;


@RequestMapping("/CustomerController")
@RestController
public class CustomerController {

    @Autowired
    private CustomerService us;

    @PostMapping("/queryAll")
    public PageResponseBean<List<Customer>> queryAll(String name,@RequestParam(required = false)Integer type,Long cur, Long number){
        return us.queryAll(name, type, cur, number);
    }

    @RequestMapping("/addCustomer")
    public ResponseBean<Integer> addCustomer(Customer customer){
        return us.addCustomer(customer);
    }

    @RequestMapping("/updateCustomer")
    public ResponseBean<Integer> updateCustomer(Customer customer){
        return us.updateCustomer(customer);
    }

    @RequestMapping("/deleteCustomer")
    public ResponseBean<Integer> deleteCustomer(Integer id){
        return us.deleteCustomer(id);
    }
    
    @PostMapping("/batchByIds")
    public ResponseBean<List<Customer>> batchByIds(@RequestParam("ids") List<Integer> ids) {
        return us.batchByIds(ids);
    }
    
    
    @GetMapping("/getById")
    public ResponseBean<Customer> getById(@RequestParam("id") Integer id) {
    	return us.getById(id);
    }

}
